﻿﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess.Classes;

public partial class Controls_Hinh : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            PopulateControls();
    }
    private void PopulateControls()
    {
        List<HangHoa> lHH = HangHoa.All();
        List<HangHoa> cHH = new List<HangHoa>();
        Random rd = new Random();
        int n = lHH.Count, a, b = -1;
        if (n <= 2)
        {
            cHH = lHH;
        }
        else
        {
            for (int i = 0; i < 2; i++)
            {
                do
                {
                    a = rd.Next(n);
                } while (a==b);
                b = a;                
                cHH.Add(lHH[a]);
            }

        }
        dlProdImg.DataSource = cHH;
        dlProdImg.DataBind();
    }
}
